<?php
namespace Home\Model;

use Think\Model\RelationModel;

class TicketModel extends RelationModel
{
    protected $_link = array(
        // 关联门票类型
        'TicketType' => array(
            'mapping_type'=> self::BELONGS_TO,
            'class_name'=>'TicketType',
            'foreign_key'=>'ticket_type_id',
            'mapping_name'=>'ticketType',
            'mapping_fields'=>'name',
            'as_fields' => 'name:type_name',
        ),
        // 关联景点
        'Attraction' => array(
            'mapping_type'=> self::BELONGS_TO,
            'class_name'=>'Attraction',
            'foreign_key'=>'attraction_id',
            'mapping_name'=>'attraction',
            'mapping_fields'=>'name',
            'as_fields' => 'name:attraction_name',
        ),
    	// 关联推荐玩法
    	'TourWay' =>array(
            'mapping_type'=> self::HAS_MANY,
            'class_name'=>'TourWay',
            'foreign_key'=>'ticket_id',
            'mapping_name'=>'tourWay',
        )
    );
}

?>